{% assign page_dir = page.dir | append: '/' | replace: '//' , '/' %}
{% for item in site.data.menu %}
  {% assign key = item[0] %}
  {% assign val = item[1] %}
  {% if page_dir contains key %}
    {% assign navtree = site.data.menu[key].subitems %}
  {% endif %}
{% endfor %}

<div class="column col-sm-2 col-xs-1 sidebar-offcanvas" id="sidebar">

<ul class="nav">
  <li><a href="#" data-toggle="offcanvas" class="visible-xs text-center"><i class="glyphicon glyphicon-chevron-right"></i></a></li>
</ul>

<ul class="nav">
  <li><a href="{{ site.baseurl }}/" data-toggle="offcanvas" class="hidden-xs text-center logo"><img src="{{ site.baseurl }}{{site.data.permanent_config.sidebar_img_path}}"/></a></li>
</ul>

<ul class="nav hidden-xs" id="lg-menu">
  <a href="{{ site.baseurl }}/" data-toggle="offcanvas" class="hidden-xs text-center logo sidebar-header"><h2>{{site.title}}</h2></a>
  <li class="dropdown text-center sidebar-header">
    {% include versions.html nav=site.data.versions %}
  </li>
  {% if page.generate_nav_for_all_versions %}
    {% for item in site.data.menu %}
      {% assign key = item[0] %}
      {% assign navtree = site.data.menu[key].subitems %}
      <div class="sidebar-navigation-container nav" id="sidbar-nav-version-{{site.data.versions[key].version}}" style="display: none;">
        {% include nav.html nav=navtree lvl=0 %}
      </div>
    {% endfor %}
  {% else %}
  <div class="sidebar-navigation-container nav">
    {% include nav.html nav=navtree lvl=0 %}
  </div>
  {% endif %}
</ul>

<!-- tiny only nav-->
<ul class="nav visible-xs" id="xs-menu">
   <li><a href="#featured" class="text-center"><i class="glyphicon glyphicon-list-alt"></i></a></li>
   <!-- <li><a href="#stories" class="text-center"><i class="glyphicon glyphicon-list"></i></a></li>
  <li><a href="#" class="text-center"><i class="glyphicon glyphicon-paperclip"></i></a></li>
    <li><a href="#" class="text-center"><i class="glyphicon glyphicon-refresh"></i></a></li>          -->
</ul>
<div id="search">
  <form role="search" action="{{ site.baseurl }}/search/" method="get">
   <input type="text" size="40" placeholder="Search" name="query">
   <input type="hidden" name="version" value="{{ version }}">
   <input type="hidden" name="baseUrl" value="{{ site.baseurl }}/{{ base_docs_path }}">
  </form>
</div>
</div>
